<template>
	<view class="express-page">
		<view class="express-list">
			<!-- 跨越物流 -->
			<view class="express-item" @click="selectExpress('跨越物流','kuayue')">
				<view class="express-info">
					<image class="express-logo" src="/static/images/express/kuayue.png" mode="aspectFit"></image>
					<view class="express-details">
						<text class="express-name">跨越物流</text>
						<text class="express-promo">{{expressPromo}}</text>
					</view>
				</view>
				<uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
			</view>

			<!-- 壹米滴答 -->
			<view class="express-item" @click="selectExpress('壹米滴答','yimidida')">
				<view class="express-info">
					<image class="express-logo" src="/static/images/express/yimidida.png"></image>
					<view class="express-details">
						<text class="express-name">壹米滴答</text>
						<text class="express-promo">{{expressPromo}}</text>
					</view>
				</view>
				<uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
			</view>

			<!-- 其他物流 -->
			<view class="express-item" @click="selectExpress('其他物流','other')">
				<view class="express-info">
					<image class="express-logo" src="/static/images/express/other.png" mode="aspectFit"></image>
					<view class="express-details">
						<text class="express-name">其他物流</text>
					</view>
				</view>
				<uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
			</view>
		</view>

		<!-- 我的物流订单按钮 -->
		<view class="my-orders">
			<uv-button shape="circle" @click="goToMyOrders" color="#fe6600" icon="order" iconColor="#FFFFFF">
				我的物流订单
			</uv-button>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'ExpressPage',
		data() {

		},
		data() {
			return {
				expressPromo: uni.getStorageSync('wanlshop:appconfig').yimi_text || '',
			};
		},
		methods: {
			// 选择物流公司
			selectExpress(expressName, expressCode) {
				// 判断是否需要认证
				let isNeedAuth = this.$store.state.common.appConfig.is_need_auth ?? 1;
				if(isNeedAuth === 1) {
					let result = this.checkUserAuth();
					if(result == true) {
						if (expressCode == 'other') {
							this.$wanlshop.msg('暂不支持当前快递');
							return false;
						}
						uni.navigateTo({
							url: `/pages/express/create?express=${expressName}&expressCode=${expressCode}`
						});
					} else {
						this.$wanlshop.msgJump('请先进行认证！','/pages/company/auth')
					}
				}
			},
			checkUserAuth() {
				let userAuth = this.$store.state.user.verify_status ?? 'no_auth';
				if(userAuth != 'success') {
					return false;
				} else {
					return true;
				}
			},
			// 跳转到我的物流订单
			goToMyOrders() {
				uni.navigateTo({
					url: '/pages/express/list'
				});
			},

			// 返回上一页
			goBack() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.express-page {
		padding: 20rpx;
		background-color: #f5f5f5;
		min-height: 100vh;
	}

	.express-list {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 0 30rpx;
		margin-bottom: 30rpx;
		box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
	}

	.express-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 40rpx 0;
		/* 增加垂直内边距 */
		border-bottom: 1rpx solid #eee;

		&:last-child {
			border-bottom: none;
		}

		&:active {
			background-color: #f9f9f9;
		}
	}

	.express-info {
		display: flex;
		align-items: center;
	}

	.express-logo {
		width: 160rpx;
		height: 100rpx;
		margin-right: 30rpx;
	}

	.express-details {
		display: flex;
		flex-direction: column;
	}

	.express-name {
		font-size: 34rpx;
		color: #333;
		margin-bottom: 10rpx;
		font-weight: 500;
	}

	.express-promo {
		font-size: 24rpx;
		color: #ff4757;
		background-color: #fff0f0;
		padding: 6rpx 16rpx;
		/* 增加内边距 */
		border-radius: 8rpx;
		width: fit-content;
	}

	.my-orders {
		padding: 0 30rpx;
		margin-top: 50rpx;

		::v-deep .uv-button {
			height: 90rpx;
			/* 增加按钮高度 */
			font-size: 32rpx;
		}
	}
</style>